package com.trover.core.http

import com.trover.core.BaseApp
import okhttp3.Cache
import okhttp3.OkHttpClient
import java.io.File

object RetrofitClientFactory : BaseRetrofitClient() {

    val service by lazy { getService(BaseApiService::class.java, BaseApiService.BASE_URL) }

    override fun handleBuilder(builder: OkHttpClient.Builder) {
        val cacheFile = File(BaseApp.CONTEXT.cacheDir, "cache")
        val cache = Cache(cacheFile, 1024 * 1024 * 100)
        builder.cache(cache)
            .addInterceptor(AddCookiesInterceptor())
            .addInterceptor(SaveCookiesInterceptor())
//            .addInterceptor()
    }
}